PROJECT (Magtlmgpu)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

set(TARGETS "feem_exe")

set(CMAKE_BUILD_TYPE "Release")


#if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
#    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall -Wno-unused-variable -pthread")
#else( CMAKE_BUILD_TYPE STREQUAL "Debug" )
#        set(CMAKE_BUILD_TYPE "Release")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -pthread -fopenmp")
#endif( CMAKE_BUILD_TYPE STREQUAL "Debug" )
message("Build Type:${CMAKE_BUILD_TYPE} ${CMAKE_CXX_FLAGS}")

# gfortran 

IF (WIN32)
	MESSAGE(STATUS "Now is windows")
ELSEIF (APPLE)
	MESSAGE(STATUS "Now is Apple systens.")
	set(GFORTRANPATH "/usr/local/lib/gcc/10")
ELSEIF (UNIX)
	MESSAGE(STATUS "Now is UNIX-like OS's.")
	set(GFORTRANPATH "/usr/lib/gcc/x86_64-linux-gnu/5")
ENDIF ()
link_directories(${GFORTRANPATH})
find_library(GFORTRAN_LIB gfortran ${GFORTRANPATH} NO_DEFAULT_PATH)
# message(${GFORTRAN_LIB})
link_libraries(${GFORTRAN_LIB})

# add openblas library
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/OpenBLAS-0.3.10/include")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/OpenBLAS-0.3.10/lib")
find_library(OPENBLAS_LIB openblas ${CMAKE_CURRENT_SOURCE_DIR}/OpenBLAS-0.3.10/lib NO_DEFAULT_PATH)
# message(${OPENBLAS_LIB})
link_libraries(${OPENBLAS_LIB} ${GFORTRAN_LIB})

add_subdirectory(gmsh)
# include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Common")     
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Geo")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Mesh")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Numeric")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Parser")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/gmsh/Post")
link_libraries(gmsh)

# message(${CMAKE_CURRENT_SOURCE_DIR})
# add superLU_MT library
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/SuperLU_MT_3.1/SRC")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/SuperLU_MT_3.1/lib")
find_library(SUPERLUMT_LIB superlu_mt ${CMAKE_CURRENT_SOURCE_DIR}/SuperLU_MT_3.1/lib NO_DEFAULT_PATH)
# message(${SUPERLUMT_LIB})
link_libraries(${SUPERLUMT_LIB})

# armadillo include
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/armadillo/include")

# FIND_PACKAGE(CUDA REQUIRED)

# set (CUDA_NVCC_FLAGS "-arch=sm_13" CACHE STRING "nvcc flags" FORCE)

# SET (CUDA_VERBOSE_BUILD ON CACHE BOOL "nvcc verbose" FORCE) 
# #HW capability 1.3

# SET(LIB_TYPE STATIC)	#set the lib type
# CUDA_ADD_LIBRARY(TestLib ${LIB_TYPE} add_vect.h add_vect.cu)


# # lib exe for HW capability 1.3
# LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/build_win64/Release)
# INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/build_win64/Release)
# CUDA_ADD_EXECUTABLE(Magtlmgpu_exe main.cpp)
# ADD_DEPENDENCIES(main_exe TestLib)
# TARGET_LINK_LIBRARIES(main_exe TestLib)


add_subdirectory(FEM)
# message(${PROJECT_SOURCE_DIR})
# target_link_libraries(${TARGETS} gmsh)



